
using System;
using System.Collections;
using System.Web.UI.WebControls;

using Awaken.Framework;
using Nullables;

namespace Northwind.Domain.Entities
{
    public partial class Product : IEntity
    {
        protected static ProductBroker broker;
        public static ProductBroker Broker
        {
            get
            {
                if (broker == null)
                {
                    broker = new ProductBroker();
                }
                return broker;
            }
        }

        #region IEntity Members

        public string EntityID
        {
            get { return string.Empty; }
        }
        
        public string EntityName
        {
            get { return string.Empty; }
        }

        public void Save()
        {
            Broker.Save(this);
        }
        
        public void Delete()
        {
            Broker.Delete(this);
        }
        
        #endregion
    
        #region Constructor
        
        public Product()
        {
            // Default, no arg constructor.
        }
        
        #endregion
            
        #region Public Properties / Protected Fields
                        
        
        protected System.Int32? _ProductID;
        public System.Int32? ProductID
        {
            get{ return _ProductID; }
            set{ _ProductID=value; }
        }
        
        protected string _ProductName;
        public string ProductName
        {
            get{ return _ProductName; }
            set{ _ProductName=value; }
        }
        
        protected System.Int32? _SupplierID;
        public System.Int32? SupplierID
        {
            get{ return _SupplierID; }
            set{ _SupplierID=value; }
        }
        
        protected System.Int32? _CategoryID;
        public System.Int32? CategoryID
        {
            get{ return _CategoryID; }
            set{ _CategoryID=value; }
        }
        
        protected string _QuantityPerUnit;
        public string QuantityPerUnit
        {
            get{ return _QuantityPerUnit; }
            set{ _QuantityPerUnit=value; }
        }
        
        protected decimal? _UnitPrice;
        public decimal? UnitPrice
        {
            get{ return _UnitPrice; }
            set{ _UnitPrice=value; }
        }
        
        protected System.Int16? _UnitsInStock;
        public System.Int16? UnitsInStock
        {
            get{ return _UnitsInStock; }
            set{ _UnitsInStock=value; }
        }
        
        protected System.Int16? _UnitsOnOrder;
        public System.Int16? UnitsOnOrder
        {
            get{ return _UnitsOnOrder; }
            set{ _UnitsOnOrder=value; }
        }
        
        protected System.Int16? _ReorderLevel;
        public System.Int16? ReorderLevel
        {
            get{ return _ReorderLevel; }
            set{ _ReorderLevel=value; }
        }
        
        protected bool? _Discontinued;
        public bool? Discontinued
        {
            get{ return _Discontinued; }
            set{ _Discontinued=value; }
        }
        
        
        
        
        
        // Many-To-One: Suppliers.SupplierID
        protected Supplier _Supplier;
        public Supplier Supplier
        {
            get{ return _Supplier; }
            set{ _Supplier=value; }
        }
        
        // Many-To-One: Categories.CategoryID
        protected Category _Category;
        public Category Category
        {
            get{ return _Category; }
            set{ _Category=value; }
        }
                
        
        
        // Many-To-Many: Order Details
        protected IList _OrderList;
        public IList OrderList
        {
            get{ return _OrderList; }
            set{ _OrderList=value; }
        }
        
        
        #endregion
    }
    
    #region ProductBroker

    public partial class ProductBroker : IBroker
    {
        #region IBroker Members

        public Type EntityType
        {
            get { return typeof(Product); }
        }
        
        public Product GetByID(object id)
        {
            return (Product)Awaken.Framework.Gateway.GetByID(EntityType, id);
        }

        public IList GetAll()
        {
            return Awaken.Framework.Gateway.GetAll(EntityType);
        }

        public void Save(IEntity entity)
        {
            Awaken.Framework.Gateway.Save(entity);
        }
        
        public void Delete(IEntity entity)
        {
            Awaken.Framework.Gateway.Delete(entity);
        }
        
        #endregion
    }
    #endregion
}
